# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=py3-ethtool
_pkgname=ethtool
pkgver=0.15
pkgrel=2
pkgdesc="Python3 library for the ethtool kernel interface"
url="https://github.com/fedora-python/python-ethtool"
arch="all"
license="GPL-2.0-only"
depends="python3"
makedepends="asciidoc libnl3-dev linux-headers py3-setuptools python3-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/fedora-python/python-ethtool/archive/v$pkgver.tar.gz
	fix-includes-and-types.patch
	"
builddir="$srcdir"/python-ethtool-$pkgver

replaces="py-ethtool" # Backwards compatibility
provides="py-ethtool=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	python3 setup.py build

	# build man-pages
	a2x -d manpage -f manpage man/pethtool.8.asciidoc
	a2x -d manpage -f manpage man/pifconfig.8.asciidoc
}

package() {
	mkdir -p "$pkgdir"/usr/bin

	# install man-pages
	install -Dm644 man/*.8 -t "$pkgdir/usr/share/man/man8"

	python3 setup.py install --skip-build --root="$pkgdir"

	# Add version suffix to executable files
	local path; for path in "$pkgdir"/usr/bin/*; do
		mv "$path" "$path"-3
	done

	# Create unsuffixed symlinks for executables from py3 subpackage
	local name; for name in pethtool pifconfig; do
		ln -s $name-3 "$pkgdir"/usr/bin/$name
	done
}

sha512sums="
82a9c08d1794f8f44e2a797d4631bacef3d492c8274d161f74d789e299f3de4830e03e863e428a14dea9713c43f10a1c743a30a504bb4c8eac03bded5c708670  py3-ethtool-0.15.tar.gz
847d7468b5897746d9bfa89d69630629b391f786c89a5d4602768bc3d5bfa84439af5cbf6832ce9b242af374031a2125c5cf119e0af93cb6f2764b238eb60828  fix-includes-and-types.patch
"
